package com.apes.scm.rbac.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.scm.rbac.model.Menu;
import com.apes.scm.rbac.model.PersonalMenuMark;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by lishikun on 2021/5/11 17:12
 */
public interface PersonalMenuMarkRepository extends CustomRepository<PersonalMenuMark, String> {

    @Query("select T from PersonalMenuMark T where T.post.id = :postId and T.user.id = :userId and T.mark = true and T.menu.terminalType.id = :terminal ")
    List<PersonalMenuMark> findByPostAndUser(@Param("postId") String postId, @Param("userId") Integer userId, @Param("terminal") String terminal);

    @Query("select T from PersonalMenuMark T where T.post.id = :postId and T.user.id = :userId and T.menu.id = :menuId ")
    List<PersonalMenuMark> findByPostAndUserAndMenu(@Param("postId") String postId, @Param("userId") Integer userId,  @Param("menuId") Integer menuId);

}
